package com.thientan.model

/**
 * Domain class used to represent entity from table KHACH_HANG
 * @author DINH HONG CHAU
 *
 */
class KhachHang {
	static constraints = {
		dienThoai(nullable: true, maxSize : 30)
		phuongXa(nullable: true, maxSize : 50)
		hoTen(maxSize: 50)
		diaChi(maxSize: 100)
		quanHuyen(maxSize: 50)
		tinhThanh(maxSize: 50)
	}

	static mapping = {
		table 'KHACH_HANG'
		id generator : 'increment'
		columns { id column : 'KHACH_HANG_ID' }
	}
	
	static transients = ['fullDiaChi']

	static belongsTo = [HopDong]
	String hoTen
	String diaChi
	String dienThoai
	String phuongXa
	String quanHuyen
	String tinhThanh
	
	public String getFullDiaChi(){
		[diaChi, phuongXa, quanHuyen, tinhThanh].join(", ")
	}
}
